package compoundDB.core;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.Test;

public class CompoundTest
{
	@Test
	public void testGetSetGUIDOwnerid()
	{
		Compound comp1 = new Compound(1, 0);
		Compound comp2 = new Compound(3, 5);
		
		assertTrue(comp1.getGUID() == 1);
		assertTrue(comp1.getOwnerID() == 0);
		assertTrue(comp2.getGUID() == 3);
		assertTrue(comp2.getOwnerID() == 5);
		
		comp1.setGUID(2);
		assertTrue(comp1.getGUID() == 2);
		comp2.setGUID(4);
		assertTrue(comp2.getGUID() == 4);
		
		comp1.setOwnerID(1);
		assertTrue(comp1.getOwnerID() == 1);
		comp2.setOwnerID(23456);
		assertTrue(comp2.getOwnerID() == 23456);
	}
	
	@Test
	public void testGetSetProperty()
	{
		Compound comp1 = new Compound(1, 0);
		Compound comp2 = new Compound(3, 6);
		
		comp1.setProperty("blergh", "blargh");
		comp1.setProperty("nameth", "namethImpl");
		comp1.setProperty("number", (Integer)3);
		comp1.setProperty("friend", comp2);
		
		assertTrue(comp1.getProperty("blergh").equals("blargh"));
		assertTrue(comp1.getProperty("nameth").equals("namethImpl"));
		assertTrue(comp1.getProperty("number").equals((Integer)3));
		assertTrue(comp1.getProperty("friend").equals(comp2));
	}
	
	@Test
	public void testGetProperties()
	{
		Compound comp1 = new Compound(1, 0);
		Compound comp2 = new Compound(3, 6);
		
		comp1.setProperty("blergh", "blargh");
		comp1.setProperty("nameth", "namethImpl");
		comp1.setProperty("number", (Integer)3);
		comp1.setProperty("friend", comp2);
		
		Map<String, Object> props1 = comp1.getProperties();
		
		assertTrue(props1.get("blergh").equals("blargh"));
		assertTrue(props1.get("nameth").equals("namethImpl"));
		assertTrue(props1.get("number").equals((Integer)3));
		assertTrue(props1.get("friend").equals(comp2));
	}
	
	@Test
	public void testGetSetNames()
	{
		Compound comp1 = new Compound(1, 0);
		
		List<String> names = new ArrayList<String>();
		names.add("name1");
		names.add("nameth77");
		
		comp1.setNames(names);
		
		assertTrue(comp1.getNames().get(0).equals("name1"));
		assertTrue(comp1.getNames().get(1).equals("nameth77"));
	}
}
